<?xml version="1.0" encoding="UTF-8"?>

<beans default-lazy-init="true" xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">

    <context:component-scan base-package="org.geoserver.taskmanager.beans"/>
    <context:component-scan base-package="org.geoserver.taskmanager.fileservice"/>

    <!--H2 setup -->
    <bean name="geomtable" class="org.geoserver.taskmanager.external.impl.GeometryTableImpl">
        <property name="nameTable" value="gw_beleid.geomtable" />
        <property name="attributeNameTable" value="table_name" />
        <property name="attributeNameGeometry" value="column_name" />
        <property name="attributeNameType" value="geometry_type" />
        <property name="attributeNameSrid" value="epsg" />
        <property name="type" value="WKT" />
    </bean>
    
    <bean class="org.geoserver.taskmanager.external.impl.H2DbSourceImpl">
        <property name="name" value="testsourcedb"/>
        <property name="path" value="mem"/>
        <property name="db" value="testsourcedb"/>
        <property name="createDBSqlResource" value="classpath:h2/dbsource/create-source.sql"/>     
        <property name="rawGeometryTable" ref="geomtable"/>
    </bean>
    
    <bean class="org.geoserver.taskmanager.external.impl.H2DbSourceImpl">
        <property name="name" value="testtargetdb"/>
        <property name="path" value="mem"/>
        <property name="db" value="testtargetdb"/>
        <property name="createDBSqlResource" value="classpath:h2/dbtarget/create-target.sql"/>
        <property name="createDataSqlResource" value=""/>
        <property name="roles">
        	<list>
        		<value>ROLE_SOMEONE</value>
        	</list>
        </property>
    </bean>
    
    <!--postgres setup -->
    <!-- <bean class="org.geoserver.taskmanager.external.impl.PostgisDbSourceImpl">
        <property name="name" value="testsourcedb"/>
        <property name="host" value="localhost" />
        <property name="db" value="testsourcedb"/>
        <property name="username" value="postgres" />
        <property name="password" value="postgres" />
    </bean>
    <bean class="org.geoserver.taskmanager.external.impl.PostgisDbSourceImpl">
        <property name="name" value="testtargetdb"/>
        <property name="host" value="localhost" />
        <property name="db" value="testtargetdb"/>
        <property name="username" value="postgres" />
        <property name="password" value="postgres" />
        <property name="roles">
        	<list>
        		<value>ROLE_SOMEONE</value>
        	</list>
        </property>
    </bean> --> 
    
    <!-- for local db pub tests, jndi -->
    <bean class="org.geoserver.taskmanager.external.impl.PostgisJndiDbSourceImpl">
        <property name="name" value="myjndidb" />
        <property name="jndiName" value="myjndi" />
        <property name="schema" value="gw_beleid" />
        <property name="targetJndiNames">
            <map>
                <entry key="mygs" value="mytargetjndi" />
            </map>
        </property>     
        <property name="roles">
        	<list>
        		<value>ROLE_SOMEONE_ELSE</value>
        	</list>
        </property> 
    </bean> 
    <!-- for remote db pub tests, postgres -->
    <bean class="org.geoserver.taskmanager.external.impl.PostgisDbSourceImpl">
        <property name="name" value="mypostgresdb" />
        <property name="host" value="localhost" />
        <property name="db" value="testtargetdb" />
        <property name="username" value="postgres" />
        <property name="password" value="postgres" />
         <property name="roles">
        	<list>
        		<value>ROLE_SOMEONE</value>
        		<value>ROLE_SOMEONE_ELSE</value>
        	</list>
        </property>      
    </bean>    

    <!-- external geoserver for testing -->
    <bean class="org.geoserver.taskmanager.external.impl.ExternalGSImpl">
        <property name="name" value="mygs"/>
        <property name="url" value="http://localhost:9090/geoserver"/>
        <property name="username" value="admin"/>
        <property name="password" value="geoserver"/>
    </bean>

    <!-- external geoserver for testing -->
    <bean class="org.geoserver.taskmanager.external.impl.ExternalKeycloakGSImpl">
        <property name="name" value="keycloakgs"/>
        <property name="url" value="http://localhost:9090/geoserver"/>
        <property name="username" value="admin"/>
        <property name="password" value="geoserver"/>
        <property name="clientId" value="clientid"/>
        <property name="clientSecret" value="clientsecret"/>
        <property name="realm" value="realm"/>
        <property name="authUrl" value="http://localhost:9090/auth"/>
    </bean>
    
    <!-- File Services -->
    <!--  don't actually use this service for file access because tests will break in windows -->
    <bean class="org.geoserver.taskmanager.external.impl.FileServiceImpl">
        <property name="rootFolder" value="/tmp"/>
        <property name="name" value="temp-directory"/>
        <property name="description" value="Temporary Directory"/>
    </bean>
   
   <!-- configure the timestamp task type -->
   <bean class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
    <property name="properties">
      <props>      
        <!--  set data directory in default file service  -->
        <prop key="timeStampTaskType.dataTimestampProperty">revisionDate</prop>
        <prop key="timeStampTaskType.metadataTimestampProperty">custom._timestamp</prop>
      </props>
    </property>  
  </bean>
    

</beans>
